package com.weng.cloud.service8881.feign;

import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: weng
 * @Date: 2022/2/19
 * @Description: com.weng.cloud.service8881.feign
 */
@RestController
public class LifeCustomer {

    @Resource
    private LifeServiceExt lifeServiceExt;
    @Resource
    private LoadBalancerClient loadBalancerClient;

    @RequestMapping(value="/shutDown",method = RequestMethod.GET)
    public String shutDown(){

        System.err.println("访问控制器成功");

        ServiceInstance instance = loadBalancerClient.choose("weng-cloud-service-8882");
        if(instance != null){
            System.out.println(instance.getInstanceId());
            System.out.println(instance.getHost());
            System.out.println(instance.getMetadata());
            System.out.println(instance.getPort());
            System.out.println(instance.getScheme());
            System.out.println(instance.getServiceId());
            System.out.println(instance.getUri());
        }

        return this.lifeServiceExt.shutDown();
    }
}
